package com.junit;

import java.util.List;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.sjzl.dao.impl.DaoImpl;
import com.sjzl.entity.Post;

public class Search {
	@Test
	public void main(){
		ApplicationContext ac = new ClassPathXmlApplicationContext(
				new String[] { "applicationContext.xml" });
		DaoImpl dao = (DaoImpl) ac.getBean("daoImpl");
		String name = "hibernate";
		
		List<Post> postList = dao.list("from Post p where p.name like '%"+ name +"%'");
		System.out.println(postList.size());
		for(Post p : postList){
			System.out.println(p.getName());
		}
	}
}
